#include <iostream>
#include<windows.h>
using namespace std;
const int N=8192;

void colTime(int *a,int **b,int n){
    int sum[n];

    for (int i=0;i<n;i++){
        sum[i]=0.0;
        for(int j=0;j<n;j++){
            sum[i]+=b[j][i]*a[j];

        }

    }




}
void rowTime(int *a,int **b,int n){
    int sum[n];


    for (int i=0;i<n;i++)
     sum[i]=0.0;
    for(int j=0;j<n;j++){
        for(int i=0;i<n;i++){
            sum[i]+=b[j][i]*a[j];

        }
    }
}
void init(int *a){
for(int i=0;i<N;i++)
        a[i]=i+1;
}




int main()
{   long long head,tail, freq;
    int **b=new int*[N];
    for(int i=0;i<N;i++){
        b[i]=new int[N];
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            b[i][j]=i+j;
        }
    }
    int *a=new int[N];
    init(a);

    QueryPerformanceFrequency((LARGE_INTEGER*)&freq);

    init(a);
    QueryPerformanceCounter((LARGE_INTEGER*)&head);
    colTime(a,b,N);
    QueryPerformanceCounter((LARGE_INTEGER*)&tail);
    cout<<"colTime: "<<(tail-head)*1000.0/freq<<"ms"<<endl;

    init(a);
    QueryPerformanceCounter((LARGE_INTEGER*)&head);
    rowTime(a,b,N);
    QueryPerformanceCounter((LARGE_INTEGER*)&tail);
    cout<<"rowTime: "<<(tail-head)*1000.0/freq<<"ms"<<endl;


}
